//
//  YZSportTrackingLine.m
//  runrun
//
//  Created by yongzhen on 16/10/22.
//  Copyright © 2016年 yongzhen. All rights reserved.
//

#import "YZSportTrackingLine.h"

@implementation YZSportTrackingLine

-(instancetype)initWithStartLocation:(CLLocation *)startLocation endLocation:(CLLocation *)endLocation
{
    
    if (self = [super init]) {
        _startLocation = startLocation;
        _endLocation = endLocation;
    }
    return  self;
    
}

- (YZSportPloyline *)polyline {
    
    CLLocationCoordinate2D coords[2];
    coords[0] = _startLocation.coordinate;
    coords[1] = _endLocation.coordinate;
    NSLog(@"speed = %f",self.speed);
    // 放大比例因子
    CGFloat factor = 8;
    CGFloat red = factor * self.speed / 255.0;
    UIColor *color = [UIColor colorWithRed:red green:1 blue:0 alpha:1];
//    NSLog(@"%f--%f---%f",)
    
//    UIColor *color = [UIColor redColor];
    return [YZSportPloyline polylineWithCoordinates:coords count:2 color:color];
}

-(double )speed
{
    
    return (_startLocation.speed + _endLocation.speed) * 0.5 * 3.6;
    
    
}

-(NSTimeInterval )time
{
    
    return [_endLocation.timestamp timeIntervalSinceDate:_startLocation.timestamp];
    
}
-(double)distance{
    return [_endLocation distanceFromLocation:_startLocation] * 0.001;
}


@end
